Indraneel's blog

Feeble attempts at grokking the incomprehensible.

What if you didn't run a service at all

Over the last decade and a half, services have become the go to solution for everything - really everything. This phenomenon has accelerated with micro services which actually encourages you to have a single purpose service for everything. Periodically however, it makes sense to check if you really need to have a service for what you have in mind.

What you pay when you use a service.

Running a service has its costs and you need to decide how far you will go to keep it running. How many web machines will you throw in to keep the service running with increasing load? How many ways will you partition the data so that your database scales? How may copies of that data will you replicate to secondaries? Do you need to put up cache machines to help offload the load?

You have to create strategies about patching, versioning, disaster recovery, hardening your servers and release. All of this costs money, time and expertise.

Write a tool and not a service.

Assume you chose to build a tool that outputs a set of html files. You need very few resources to serve static html pages, a few orders of magnitude less actually. There are no databases to partition or data to replicate. Caching is free, others will do it for you. In fact, if your site goes viral, then you will likely survive the massive surge in traffic far better if you served static pages.

If you are worried that you will lose the benefits of a service like responsiveness then there are quite a few ways to counter that. You can continue to use javascript, and since you control the frequency with which the tool runs, you can continue to refresh the contents of the html pages as often as you want.

Plus it is often much easier to update the tool with out causing any downtime, or having to worry about versioning. Simply ensure that when testing changes to the tool, make it output files to a different directory. Once you feel comfortable, output the files to the desired directory.

Serving static files to the public is so basic, that multiple mainstream vendors make it easy. Dropbox, Amazon S3, Azure Blobs all support it, often for free. If you evaluate this strategy of generating static pages and find it good enough for you, then you will likely save yourself a world of pain by using it.